package sphere.view;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import sphere.controller.SphereController;

public class SphereWindow extends Frame{

	private static final long serialVersionUID = -6467201332047225808L;
	private static final String RADIUS = "Rayon : ";
	private static final String VOLUME = "Volume : ";
	private static final String SURFACE = "Surface : ";
	private TextField textRadius;
	private TextField textVolume;
	private TextField textSurfaceArea;
	private Label label1, label2, label3;
	private Panel p1;
	SphereController sphereControlleur;
	
	protected class PrivListener extends WindowAdapter
    {
            public void windowClosing (WindowEvent e )
            {
                    System.exit(0) ;
            }
    }
  
	public SphereWindow(String title){
		super(title);
		PrivListener monListener = new PrivListener();
        this.addWindowListener(monListener);
		setLayout(new FlowLayout(FlowLayout.LEFT));
		p1 = new Panel();
		p1.setLayout(new GridLayout(3, 2, 10, 10));//(nbligne, nbColonne)
		
		label1 = new Label(RADIUS);
		label2 = new Label(VOLUME);
		label3 = new Label(SURFACE);
		
		textRadius = new TextField();
		SphereController monListener2 = new SphereController(this);
		textRadius.addTextListener(monListener2);
		textVolume = new TextField();
		textVolume.setEditable(false);
		textSurfaceArea = new TextField();
		textSurfaceArea.setEditable(false);
		
		add(p1);
		p1.add(label1);
		p1.add(textRadius);
		p1.add(label2);
		p1.add(textVolume);
		p1.add(label3);
		p1.add(textSurfaceArea);
		
		this.pack();
		this.setVisible(true);
		this.setResizable(false);
		
	}



	public void setTextVolume(String textVolume) {
		this.textVolume.setText(textVolume);
	}



	public void setTextSurfaceArea(String textSurfaceArea) {
		this.textSurfaceArea.setText(textSurfaceArea);
	}
	
	
	
	/*this.addWindowListener(new MonWindowListener());*/

}
